package com.servicesystem.servicesystem.untis;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class GetImageUrl {

    public static ArrayList<String> getUrl(String resources) {
        resources = resources.replace("\\", "");
        List<String> img = getImg(resources);
        ArrayList<String> result = new ArrayList<>();
        for (String s : img) {
            Pattern p1 = Pattern.compile("(?<=\").*?(?=\")");
            Matcher m = p1.matcher(s);
            while (m.find()) {
                result.add(m.group());
            }
        }
        return result;
    }

    public static List<String> getImg(String s) {
        String regex;
        List<String> list = new ArrayList<String>();
        regex = "src=\"(.*?)\"";
        Pattern pa = Pattern.compile(regex, Pattern.DOTALL);
        Matcher ma = pa.matcher(s);
        while (ma.find()) {
            list.add(ma.group());
        }
        return list;
    }
}
